import React, { Component } from 'react';
import { Tabs, Button, Table, Divider, Modal, Form, Input, Icon, Select,  Tree, Drawer, Row, Col } from 'antd';
import '@/assets/css/settings';
import '@/assets/css/store';
import * as APIService from '../../axios/api';
import { withRouter } from "react-router-dom";
import '@/assets/css/tag_batch.scss'
import 'antd/dist/antd.css';
import * as utils from '../../utils_yyr/action';
import * as LService from '../../axios/api_lqy';
const { TabPane } = Tabs;
const { confirm } = Modal;
const { TreeNode } = Tree;
const { Option } = Select;


class Settings extends Component {
	constructor(props) {
		super(props);
		this.state = {
			loading: false, dataSource: [], visible: false,
			modalData: '', menuList: [], firstLevel: '', secondLevel: '',
			options: [], handleType: 0, topId: 0, btnDrawer: false,
			editingKey: '', btnData: [], submitType: 0, printRacksList: [],
			visible_two: false, expandedKeys: [], treeData: [], table1: [], table2: [],
			parentId: '', visible_three: false, storageLocationLong: '', treeNodeType: '0',
			editData: [], visible_store: false, visible_area: false, visible_goods: false, visible_storage: false, addStorage: 0,
		};

	}

	//周期函数
	componentDidMount() {
		this.fetch();
	}

	//初始化加载数据
	fetch = () => {
		this.setState({ loading: true })
		APIService.findDepot().then(data => {
			var dataSource = data.data.data;
			for (var i = 0; i < dataSource.length; i++) {
				if (dataSource[i] === null) {
					dataSource.splice(i, 1);
				}
			}
			this.setState({
				menuList: dataSource,
				loading: false,
				treeData: dataSource
			})
		})
	}



	//弹出删除框
	showDeleteConfirm = (data, type) => {
		const { parentId } = this.state
		const that = this;
		if (parentId === '') {
			utils.openNotification('warning', '请选择库房');

		} else {
			confirm({
				title: '确认删除？',
				okText: '确认',
				okType: 'danger',
				cancelText: '取消',
				onOk() {
					if (type === 1) {
						LService.deleteDepotlById(parentId).then(data => {
							if (data.data.code === 200) {
								utils.openNotification('success', '删除成功')
								that.fetch();
								that.storeClick(parentId);
							} else if (data.data.code === 300) {
								utils.openNotification('warning', data.data.msg)
							}
						})
					} else if (type === 2) {
						LService.deleteRegionlById(data.id, data.treeId).then(data => {
							if (data.data.code === 200) {
								utils.openNotification('success', '删除成功')
								that.fetch();
								that.storeClick(parentId);
							} else if (data.data.code === 300) {
								utils.openNotification('warning', data.data.msg)
							}
						})
					}
					else if (type === 3) {
						LService.deleteShelevslById(data.id, data.treeId).then(data => {
							if (data.data.code === 200) {
								utils.openNotification('success', '删除成功')
								that.fetch();
								that.regionClick(parentId);
							} else if (data.data.code === 300) {
								utils.openNotification('warning', data.data.msg)
							}
						})
					}
					else if (type === 4) {
						LService.deleteStoragelById(data.id, data.treeId).then(data => {
							if (data.data.code === 200) {
								utils.openNotification('success', '删除成功')
								that.fetch();
								that.shelevsClick(parentId);
							} else if (data.data.code === 300) {
								utils.openNotification('warning', data.data.msg)
							}
						})
					}


				},
				onCancel() {
					console.log('Cancel');
				},
			});
		}

	}




	//0新增  1修改 
	add_edit = (data, type, treeType) => {
		console.log(type + '-' + treeType)
		if (type === 1 && treeType === '1') {
			this.props.form.setFieldsValue({
				storageLocationCod: data.storageLocationCod,
				storageLocationName: data.storageLocationName,
				grade: data.grade,
			})
		} else if (type === 1 & treeType === '2') {
			this.props.form.setFieldsValue({
				regionName: data.regionName,
				regionNo: data.regionNo,
				regionLocate: data.regionLocate,
				regionLocateNo: data.regionLocateNo,
				regionArea: data.regionArea,

			})
		}
		else if (type === 1 & treeType === '3') {
			this.props.form.setFieldsValue({
				shelvesName: data.shelvesName,
				shelvesNo: data.shelvesNo,
				shelvesArea: data.shelvesArea,
				shelvesLong: data.shelvesLong,
				shelvesWide: data.shelvesWide,
				shelvesHigh: data.shelvesHigh,
			})
		}
		else if (type === 1 & treeType === '4') {
			this.props.form.setFieldsValue({
				storageLocationCod_storage: data.storageLocationCod,
				theHighestInventory: data.theHighestInventory,
				minimumStockQuantity: data.minimumStockQuantity,
				safetyStock: data.safetyStock,
				materialName: data.materialName,
				congruentRelationship: data.congruentRelationship,
				supplierCode: data.supplierCode,
				purchaseOrderTyp: 1,
				materialCode: data.materialCode,
				storageLocationLong: data.storageLocationLong,
				storageLocationWide: data.storageLocationWide,
				storageLocationHigh: data.storageLocationHigh,
				peakLoad: data.peakLoad,
			})
		}
		let store = false;
		let area = false;
		let goods = false;
		let storage = false;
		if (type === 0 & treeType === '0') {
			store = true;
		} else if (type === 1 & treeType === '1') {
			store = true;
		} else if (type === 0 & treeType === '1') {
			area = true
		} else if (type === 1 & treeType === '2') {
			area = true
		} else if (type === 0 & treeType === '2') {
			goods = true
		} else if (type === 1 & treeType === '3') {
			goods = true
		} else if (type === 0 & treeType === '3') {
			storage = true
		} else if (type === 1 & treeType === '4') {
			storage = true
			this.setState({
				addStorage: 1
			})
		}
		this.setState({
			visible_store: store,
			visible_area: area,
			visible_goods: goods,
			visible_storage: storage,
			editData: data,
			handleType: type,
		});
	};

	//drawer取消
	onClose = () => {
		this.props.form.resetFields();
		this.setState({
			visible_store: false,
			visible_area: false,
			visible_goods: false,
			visible_storage: false,
		});
	};

	//库房提交
	submit_store = (e) => {
		this.props.form.validateFields(['storageLocationCod', 'storageLocationName', 'grade'], (err, values) => {
			if (!err) {
				if (this.state.handleType === 1) {
					values = Object.assign({}, values, { id: this.state.editData.id })
					LService.updateDepotManagement(values).then(data => {
						if (data.data.code === 200) {
							utils.openNotification('success', '修改成功')
							this.onClose();
							this.fetch();
							this.storeClick(this.state.parentId)
						} else if (data.data.code === 300) {
							utils.openNotification('warning', data.data.msg)
						}
					})
				} else {
					LService.addDepot(values).then(data => {
						if (data.data.code === 200) {
							utils.openNotification('success', '新增成功')
							this.onClose();
							this.fetch();
						} else if (data.data.code === 300) {
							utils.openNotification('warning', data.data.msg)
						}
					})
				}


			}
		}
		);
	}
	//区域提交
	submit_area = (e) => {
		this.props.form.validateFields(['regionName', 'regionNo', 'regionLocate', 'regionLocateNo', 'regionArea'], (err, values) => {
			if (!err) {
				if (this.state.handleType === 1) {
					values = Object.assign({}, values, { id: this.state.editData.id })
					LService.updateRegion(values).then(data => {
						if (data.data.code === 200) {
							utils.openNotification('success', '修改成功')
							this.onClose();
							this.fetch();
							this.regionClick(this.state.parentId)
						} else if (data.data.code === 300) {
							utils.openNotification('warning', data.data.msg)
						}
					})
				} else {
					values = Object.assign({}, values, { parentId: this.state.parentId })
					LService.addRegion(values).then(data => {
						if (data.data.code === 200) {
							utils.openNotification('success', '新增成功')
							this.onClose();
							this.fetch();
							this.storeClick(this.state.parentId);
						} else if (data.data.code === 300) {
							utils.openNotification('warning', data.data.msg)
						}
					})
				}

			}
		}
		);
	}
	//货架提交
	submit_goods = (e) => {
		this.props.form.validateFields(['shelvesName', 'shelvesNo', 'shelvesArea', 'shelvesLong', 'shelvesWide', 'shelvesHigh'], (err, values) => {
			if (!err) {

				if (this.state.handleType === 1) {
					values = Object.assign({}, values, { id: this.state.editData.id })
					LService.updateShelves(values).then(data => {
						if (data.data.code === 200) {
							utils.openNotification('success', '修改成功')
							this.onClose();
							this.fetch();
							this.shelevsClick(this.state.parentId)
						} else if (data.data.code === 300) {
							utils.openNotification('warning', data.data.msg)
						}
					})
				} else {
					values = Object.assign({}, values, { parentId: this.state.parentId })
					LService.addShelves(values).then(data => {
						if (data.data.code === 200) {
							utils.openNotification('success', '新增成功')
							this.onClose();
							this.fetch();
							this.regionClick(this.state.parentId);
						} else if (data.data.code === 300) {
							utils.openNotification('warning', data.data.msg)
						}
					})
				}
			}
		}
		);
	}
	//储位提交
	submit_storage = (e) => {
		this.props.form.validateFields(['storageLocationCod_storage', 'materialName', 'materialCode',
			'purchaseOrderType', 'supplierCode', 'minimumStockQuantity', 'safetyStock',
			'theHighestInventory', 'storageLocationLong', 'storageLocationWide', 'storageLocationHigh', 'peakLoad'], (err, values) => {
				if (!err) {
					if (this.state.handleType === 1) {
						values = Object.assign({}, values, { id: this.state.editData.id, storageLocationCod: values.storageLocationCod_storage })
						delete values['storageLocationCod_storage']
						LService.updateStorage(values).then(data => {
							if (data.data.code === 200) {
								utils.openNotification('success', '修改成功')
								this.onClose();
								this.fetch();
								this.shelevsClick(this.state.parentId)
							} else if (data.data.code === 300) {
								utils.openNotification('warning', data.data.msg)
							}
						})
					} else {
						values = Object.assign({}, values, { parentId: this.state.parentId, storageLocationCod: values.storageLocationCod_storage })
						delete values['storageLocationCod_storage']
						LService.addStorage(values).then(data => {
							if (data.data.code === 200) {
								utils.openNotification('success', '新增成功')
								this.onClose();
								this.fetch();
								this.shelevsClick(this.state.parentId);
							} else if (data.data.code === 300) {
								utils.openNotification('warning', data.data.msg)
							}
						})
					}
				}
			}
		);
	}



	//点击库房
	storeClick = (id) => {
		LService.depotListById(id).then(data => {
			this.setState({
				table1: data.data.data === null ? [] : [data.data.data]
			})
		})
		LService.findAllRegionById(id).then(data => {
			var dataSource = data.data.data
			for (var i = 0; i < dataSource.length; i++) {
				if (dataSource[i] === null) {
					dataSource.splice(i, 1);
				}
			}
			console.log(dataSource)
			this.setState({
				table2: dataSource
			})
		})
	}
	//点击区域
	regionClick = (id) => {
		LService.findRegionDetailById(id).then(data => {
			this.setState({
				table1: data.data.data === null ? [] : [data.data.data]
			})
		})
		LService.findAllShelvesById(id).then(data => {
			var dataSource = data.data.data
			for (var i = 0; i < dataSource.length; i++) {
				if (dataSource[i] === null) {
					dataSource.splice(i, 1);
				}
			}

			this.setState({
				table2: dataSource
			})
		})
	}
	//点击货架
	shelevsClick = (id) => {
		LService.findShelvesDetailById(id).then(data => {
			this.setState({
				table1: data.data.data === null ? [] : [data.data.data]
			})
		})
		LService.findStorageById(id).then(data => {
			var dataSource = data.data.data
			for (var i = 0; i < dataSource.length; i++) {
				if (dataSource[i] === null) {
					dataSource.splice(i, 1);
				}
			}

			this.setState({
				table2: dataSource
			})
		})
	}

	//生成树
	renderTreeNodes = data =>
		data.map(item => {
			if (item.children) {
				return (
					<TreeNode title={item.storageLocationName} selectable={item.type === '4' ? false : true} key={item.id} icon={<Icon type='cluster' />} dataRef={item}>
						{this.renderTreeNodes(item.children)}
					</TreeNode>
				);
			}
			return <TreeNode key={item.id} {...item} dataRef={item} />;
		});

	onSelect = (selectedKeys, e) => {
		let nodeType = e.node.props.dataRef.type
		if (selectedKeys.length !== 0) {
			this.setState({ treeNodeType: nodeType, parentId: selectedKeys[0] })
			if (nodeType === '1') {
				this.storeClick(selectedKeys[0]);

			} else if (nodeType === '2') {
				this.regionClick(selectedKeys[0]);
			}
			else if (nodeType === '3') {
				this.shelevsClick(selectedKeys[0]);

			}

		}

	}


	//页面跳转
	handleClick(path) {
		this.props.history.push(path);
	}



	render() {
		const type = this.state.treeNodeType;
		const editData = this.state.editData;
		const columns = [
			{
				dataIndex: '',
				width: '80px'
			},

			{
				title: '编码',
				dataIndex: 'storageLocationCod',
			},

			{
				title: '名称',
				dataIndex: 'storageLocationName',
			},

			{
				title: '级别',
				dataIndex: 'grade',
			},
			{
				title: '操作',
				width: '12%',
				render: (text, record) => {
					return <span>
						<a onClick={() => this.add_edit(record, 1, this.state.treeNodeType)}>修改</a>
					</span>
				}
			}
		];
		const column_area = [


			{
				title: '编码',
				dataIndex: 'regionNo',
			},

			{
				title: '名称',
				dataIndex: 'regionName',
			},

			{
				title: '区域',
				dataIndex: 'regionLocate',
			},
			{
				title: '所在位置',
				dataIndex: 'regionLocateNo',
			},
			{
				title: '面积',
				dataIndex: 'regionArea',
			},
			{
				title: '操作',
				width: '12%',
				render: (text, record) => {
					return type === '2' ? <span>
						<a onClick={() => this.add_edit(record, 1, this.state.treeNodeType)}>修改</a>
					</span> : <span>
							<a onClick={() => this.showDeleteConfirm(record, 2)}>删除</a>
						</span>
				}
			}
		];
		const column_goods = [


			{
				title: '编码',
				dataIndex: 'shelvesNo',
			},

			{
				title: '名称',
				dataIndex: 'shelvesName',
			},

			{
				title: '面积',
				dataIndex: 'shelvesArea',
			},

			{
				title: '长',
				dataIndex: 'shelvesLong',
			},
			{
				title: '宽',
				dataIndex: 'shelvesWide',
			},
			{
				title: '高',
				dataIndex: 'shelvesHigh',
			},
			{
				title: '操作',
				width: '12%',
				render: (text, record) => {
					return type === '3' ? <span>
						<a onClick={() => this.add_edit(record, 1, this.state.treeNodeType)}>修改</a>
					</span> : <span>
							<a onClick={() => this.showDeleteConfirm(record, 3)}>删除</a>
						</span>
				}
			}

		];

		const column_storage = [

			{
				title: '编码',
				dataIndex: 'storageLocationCod',
			},

			{
				title: '存放物料名称',
				dataIndex: 'materialName',
			},

			{
				title: '物料编码',
				dataIndex: 'materialCode',
			},

			{
				title: '采购订单类型',
				dataIndex: 'purchaseOrderType',
			},

			{
				title: '盒子数量',
				dataIndex: 'boxNumber',
			},

			{
				title: '供应商编码',
				dataIndex: 'supplierCode',
			},

			{
				title: '最低库存量',
				dataIndex: 'minimumStockQuantity',
			},

			{
				title: '安全库存量',
				dataIndex: 'safetyStock',
			},

			{
				title: '最高库存量',
				dataIndex: 'theHighestInventory',
			},

			{
				title: '长',
				dataIndex: 'storageLocationLong',
			},

			{
				title: '宽',
				dataIndex: 'storageLocationWide',
			},

			{
				title: '高',
				dataIndex: 'storageLocationHigh',
			},

			{
				title: '最多载重',
				dataIndex: 'peakLoad',
			},
			{
				title: '操作',
				width: '12%',
				render: (text, record) => {
					return <span>
						<a onClick={() => this.add_edit(record, 1, '4')}>修改</a>
						<Divider type="vertical" />
						<a onClick={() => this.showDeleteConfirm(record, 4)}>删除</a>
					</span>
				}
			}

		]


		const { getFieldDecorator } = this.props.form;
		const formItemLayout_addMenu = {
			labelCol: {
				sm: { span: 8 }
			},
			wrapperCol: {
				sm: { span: 9 }
			}
		};
		const formItemLayout = {
			labelCol: {
				xs: {
					span: 30
				},
				sm: {
					span: 10
				},
			},
			wrapperCol: {
				xs: {
					span: 24
				},
				sm: {
					span: 14
				},
			},
		};







		// var operations = <div className="mydiv" > <Button icon="plus" onClick={()=>this.showDetail([],0)} type="primary" > 新增 </Button></div >
		return (
			<div className="radius" >

				<div>
					<div className="wenzi">
						<span> 库房管理</span>
					</div>
					<div class="ant-btn-group" style={{ float: 'right' }}>
						<Button type="button" className="ant-btn ant-btn-primary" icon="plus" onClick={() => this.add_edit(null, 0, '0')}></Button>
						<Button type="button" className="ant-btn ant-btn-primary" icon="delete" onClick={() => this.showDeleteConfirm(null, 1)} onDelete={this.onDelete}></Button>
					</div>
					<Divider />

					<Tree onSelect={this.onSelect} showLine={true} showIcon={true} className="tree">
						{this.renderTreeNodes(this.state.treeData)}
					</Tree>
				</div>

				<div>
					<Tabs style={{ backgroundColor: 'white', height: '18rem' }}>
						
						<TabPane tab={<span><Icon type="dropbox" />{type === '1' ? '库房信息' : type === '2' ? '区域信息' : type === '3' ? '货架信息' : '详细信息'}</span>} key="1">
							<Table columns={type === '1' ? columns : type === '2' ? column_area : type === '3' ? column_goods : columns} rowKey={(record) => record.id} dataSource={this.state.table1} pagination={false} loading={this.state.loading}  size="small"/>
						</TabPane>
					</Tabs>

					<Tabs style={{ backgroundColor: 'white', marginTop: '5px', height: '33.5rem' }} tabBarExtraContent={<div style={{ margin: '15px' }} > <Button icon="plus" onClick={() => this.add_edit(null, 0, this.state.treeNodeType)} type="primary" > 新增 </Button></div >} >
						<TabPane tab={<span><Icon type="appstore" />{type === '1' ? '区域信息' : type === '2' ? '货架信息' : type === '3' ? '储位信息' : type === '4' ? '储位详情' : '详细信息'}</span>} key="1">
							<Table columns={type === '1' ? column_area : type === '2' ? column_goods : type === '3' ? column_storage : column_area} rowKey={(record) => record.id} dataSource={this.state.table2} pagination={false} loading={this.state.loading} onExpand={(expanded, record) => this.onExpand(expanded, record)} size="small"/>
						</TabPane>
					</Tabs>
				</div>



				<Drawer
					width='600px'
					title="新增/修改库房信息"
					visible={this.state.visible_store}
					centered
					onClose={this.onClose}
				>
					<Form  {...formItemLayout} layout='Horizontal'>

						<Col span={12} >
							<Form.Item label={'请输入编码'}>
								{getFieldDecorator('storageLocationCod', { rules: [{ required: true, message: '请输入编码'}] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'请输入名称'}>
								{getFieldDecorator('storageLocationName', { rules: [{ required: true, message: '请输入名称' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'请输入级别'}>
								{getFieldDecorator('grade', { rules: [{ required: true, message: '请输入级别' }] })(<Input />)}
							</Form.Item>
						</Col>
					</Form>
					<div className="drawer_foot">
						<Button onClick={this.onClose} style={{ marginRight: 8 }}>取消</Button>
						<Button onClick={this.submit_store} type="primary">确定</Button>
					</div>

				</Drawer>


				<Drawer
					width='600px'
					title="新增/修改区域信息"
					visible={this.state.visible_area}
					centered
					onClose={this.onClose}
				>
					<Form  {...formItemLayout} layout='Horizontal'>

						<Col span={12} >
							<Form.Item label={'编码'}>
								{getFieldDecorator('regionNo', { rules: [{ required: true, message: '请输入编码' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'名称'}>
								{getFieldDecorator('regionName', { rules: [{ required: true, message: '请输入名称' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'区域'}>
								{getFieldDecorator('regionLocate', { rules: [{ required: true, message: '请输入级别' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'所在位置'}>
								{getFieldDecorator('regionLocateNo', { rules: [{ required: true, message: '请输入所在位置' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'面积'}>
								{getFieldDecorator('regionArea', { rules: [{ required: true, message: '请输入面积' }] })(<Input />)}
							</Form.Item>
						</Col>
					</Form>
					<div className="drawer_foot">
						<Button onClick={this.onClose} style={{ marginRight: 8 }}>取消</Button>
						<Button onClick={this.submit_area} type="primary">确定</Button>
					</div>

				</Drawer>
				<Drawer
					width='600px'
					title="新增/修改货架信息"
					visible={this.state.visible_goods}
					centered
					onClose={this.onClose}
				>
					<Form  {...formItemLayout} layout='Horizontal'>

						<Col span={12} >
							<Form.Item label={'编码'}>
								{getFieldDecorator('shelvesNo', { rules: [{ required: true, message: '请输入编码' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'名称'}>
								{getFieldDecorator('shelvesName', { rules: [{ required: true, message: '请输入名称' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'面积'}>
								{getFieldDecorator('shelvesArea', { rules: [{ required: true, pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入面积(数字类型)' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'长'}>
								{getFieldDecorator('shelvesLong', { rules: [{ required: true, pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入长度(数字类型)' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'宽'}>
								{getFieldDecorator('shelvesWide', { rules: [{ required: true, pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入宽度(数字类型)' }] })(<Input />)}
							</Form.Item>
						</Col>
						<Col span={12} >
							<Form.Item label={'高'}>
								{getFieldDecorator('shelvesHigh', { rules: [{ required: true, pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入高度(数字类型)' }] })(<Input />)}
							</Form.Item>
						</Col>
					</Form>
					<div className="drawer_foot">
						<Button onClick={this.onClose} style={{ marginRight: 8 }}>取消</Button>
						<Button onClick={this.submit_goods} type="primary">确定</Button>
					</div>

				</Drawer>

				<Drawer
					width='600px'
					title="新增/修改储位信息"
					visible={this.state.visible_storage}
					centered
					onClose={this.onClose}
				>
					<Form  {...formItemLayout} layout='Horizontal'>
						<Row gutter={16}>
							<Col span={12}>
								<Form.Item label="编码">
								{/* pattern:new RegExp(/^[1-3][1-6][A-C][0-9][1-9][1-9][0-9][1-9]$/, "g") */}
									{getFieldDecorator('storageLocationCod_storage', { rules: [{ required: true ,message:"请输入正确的编码(eg:13A01101)" }] })(<Input placeholder="请输入编码" disabled/>)}
								</Form.Item>
							</Col>
							<Col span={12}>
								<Form.Item label="存放物料名称">
									{getFieldDecorator('materialName', { rules: [{ message:"请输入存放物料名称"}] })(<Input placeholder="请输入存放物料名称" />)}
								</Form.Item>
							</Col>
						</Row>

						<Row gutter={16}>
							<Col span={12}>
								<Form.Item label="物料编码">
									{getFieldDecorator('materialCode', { rules: [{ message: "请输入物料编码"}] })(<Input placeholder="请输入物料编码" />)}
								</Form.Item>
							</Col>
							<Col span={12}>
								<Form.Item label="采购订单类型">
									{getFieldDecorator('purchaseOrderType', { initialValue: this.state.addStorage === 0 ? '1' : editData.purchaseOrderType + '' })(
										<Select placeholder="请输入采购订单类型" >
											<Option value="1">VMI</Option>
											<Option value="2">非VMI</Option>
											<Option value="3">客供</Option>
											<Option value="4">样件</Option>
										</Select>
									)
									}
								</Form.Item>
							</Col>
						</Row>


						<Row gutter={16}>
							<Col span={12}>
								<Form.Item label="供应商编码">
									{getFieldDecorator('supplierCode', { rules: [{message:"请输入供应商编码"}] })(<Input placeholder="请输入供应商编码" />)}
								</Form.Item>
							</Col>
							<Col span={12}>
								<Form.Item label="最低库存量">
									{getFieldDecorator('minimumStockQuantity', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入最低库存量(数字类型)' }] })(<Input placeholder="请输入最低库存量" />)}
								</Form.Item>
							</Col>
						</Row>

						<Row gutter={16}>
							<Col span={12}>
								<Form.Item label="安全库存量">
									{getFieldDecorator('safetyStock', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入安全库存量(数字类型)' }] })(<Input placeholder="请输入安全库存量" />)}
								</Form.Item>
							</Col>
							<Col span={12}>
								<Form.Item label="最高库存量">
									{getFieldDecorator('theHighestInventory', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入最高库存量(数字类型)' }] })(<Input placeholder="请输入最高库存量" />)}
								</Form.Item>
							</Col>
						</Row>

						<Row gutter={16}>
							<Col span={12}>
								<Form.Item label="长">
									{getFieldDecorator('storageLocationLong', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入长度(数字类型)' }] })(<Input placeholder="请输入长度" />)}
								</Form.Item>
							</Col>
							<Col span={12}>
								<Form.Item label="宽">
									{getFieldDecorator('storageLocationWide', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入宽度(数字类型)' }] })(<Input placeholder="请输入宽度" />)}
								</Form.Item>
							</Col>
						</Row>

						<Row gutter={16}>
							<Col span={12}>
								<Form.Item label="高">
									{getFieldDecorator('storageLocationHigh', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入高度(数字类型)' }] })(<Input placeholder="请输入高度" />)}
								</Form.Item>
							</Col>
							<Col span={12}>
								<Form.Item label="最多载重">
									{getFieldDecorator('peakLoad', { rules: [{ pattern: new RegExp(/^[1-9]\d*$/, "g"), message: '请输入最多载重(数字类型)' }] })(<Input placeholder="请输入最多载重" />)}
								</Form.Item>
							</Col>
						</Row>

					</Form>

					<div className="drawer_foot">
						<Button onClick={this.onClose} style={{ marginRight: 8 }}>取消</Button>
						<Button onClick={this.submit_storage} type="primary">确定</Button>
					</div>

				</Drawer>

			</div>


		);
	}
}
export default Form.create()(withRouter(Settings));